package com.wdc.贪心;

public class E02Leetcode376 {
    public int wiggleMaxLength(int[] nums) {
        int res = 1;
        int preEDiff = 0;
        int curEDiff = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            curEDiff = nums[i + 1] - nums[i];
            if ((preEDiff >= 0 && curEDiff < 0) ||(preEDiff <= 0 && curEDiff > 0)){
                res += 1;
                preEDiff = curEDiff;
            }
        }
        return res;
    }
}
